<?php

namespace frontend\modules\member\models;

use common\helpers\Url;

/**
 * MemberApplySearch is the search model class for table "{{%shop_activity_product}}".
 *
 * @author emhome <emhome@163.com>
 * @since 1.0
 */
class MemberDataSearch extends \frontend\models\MemberSearch {

    /**
     * {@inheritdoc}
     */
    public function getCanUpdate() {
        if (in_array($this->audit_status, [static::AUDIT_STATUS_REJECT, static::AUDIT_STATUS_DEFAULT, static::AUDIT_STATUS_SUBMIT])) {
            return true;
        }
        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function getCanSubmit() {
        if (in_array($this->audit_status, [static::AUDIT_STATUS_REJECT, static::AUDIT_STATUS_DEFAULT])) {
            return true;
        }
        return false;
    }

    /**
     * {@inheritdoc}
     */
    public function getNotice() {
        if ($this->audit_status == static::AUDIT_STATUS_REJECT) {
            return [
                'title' => '抱歉，您的会员申请未通过。补充资料',
                'content' => $this->audit_mark,
                'link' => Url::weblink('member/apply/{id}', [
                    'id' => $this->type_id
                ])
            ];
        } elseif ($this->audit_status == static::AUDIT_STATUS_DEFAULT || $this->audit_status == static::AUDIT_STATUS_SUBMIT) {
            return [
                'title' => '会员申请资料已提交，等待审核',
                'content' => $this->audit_mark,
                'link' => Url::weblink('member/apply/{id}', [
                    'id' => $this->type_id
                ])
            ];
        }
        return null;
    }

    /**
     * {@inheritdoc}
     */
    public function fields() {
        return [
            'canUpdate',
            'canSubmit',
            'notice',
            'fullData',
        ];
    }

}
